﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;


namespace Store_Api.Modelo
{
    public class Mail
    {
        public bool enviarMail(string mailTo, string asunto, string mensaje, string adjunto)
        {
            try
            {
                MailMessage m = new MailMessage();
                SmtpClient sc = new SmtpClient();

                //m.From = new MailAddress("store@timesolution.com.ar", "Store Solution");
                m.From = new MailAddress("escuela.ailem@gmail.com", "Escuela Ailem");
                m.To.Add(new MailAddress(mailTo));

                
                // m.Bcc.Add(new MailAddress(TheCompanyEmail));
                //similarly BCC


                m.Subject = asunto;
                m.IsBodyHtml = true;
                m.Body = mensaje;
                if(adjunto!=null)
                    m.Attachments.Add(new Attachment(adjunto));

                //sc.Host = "smtp1.redynet.com.ar";
                //sc.Port = 2025;
                //sc.Credentials = new
                //System.Net.NetworkCredential("store@timesolution.com.ar", "store");
                //sc.EnableSsl = false;
                //sc.Send(m);
                //return true;

                sc.Host = "smtp.gmail.com";
                sc.Port = 587;
                sc.Credentials = new
                System.Net.NetworkCredential("escuela.ailem@gmail.com", "escuela1234");
                sc.EnableSsl = true;
                sc.Send(m);
                return true;

                //sc.Host = "mail.ameport.org";
                //sc.Port = 25;
                //sc.Credentials = new System.Net.NetworkCredential("validacion@ameport.org.ar", "Valido2014");
                ////sc.UseDefaultCredentials = true;
                //sc.EnableSsl = false;
                //sc.Send(m);
                //return true;

            }
           catch (Exception ex)
            {
                
                return false;
            }


        }
    }
}
